package Test_2019_2_18;

import java.util.Scanner;

/**
 * 3、输入 3 个整数，编写程序求一元二次方程的根。（ax² + bx + c = 0）
 */
public class Test3 {
    public static void main(String[] args) {
        System.out.println("3、输入 3 个整数，编写程序求一元二次方程的根。");
        Scanner sc = new Scanner(System.in);
        System.out.println("输入2次方的系数");
        int a = sc.nextInt();
        System.out.println("输入1次方的系数");
        int b = sc.nextInt();
        System.out.println("输入0次方的系数");
        int c = sc.nextInt();
        double x1 = (-b + Math.sqrt(b * b - 4 * a * c)) / 2 * a;
        double x2 = (-b - Math.sqrt(b * b - 4 * a * c)) / 2 * a;
        System.out.println("根分别是 " + x1 + "," + x2);
    }
}
